﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using Titan.Test.Entity;
using System.Data;
using Titan;
using Oracle.DataAccess.Client;
using System.Text;

namespace Titan.Test
{
    
    
    /// <summary>
    ///这是 DbSessionTest 的测试类，旨在
    ///包含所有 DbSessionTest 单元测试
    ///</summary>
    [TestClass]
    public class LamdaTest
    {
        

        public LamdaTest()
        {
            
        }
         
        
         

        [TestMethod]
        public void SelectCollectionTest()
        {

            QueryExpression<Customer>  q = new QueryExpression<Customer>();
            q.Selects.Add(x => x.CustomerId);
            q.Wheres.Add(x => x.CustomerId > 5);
            q.Wheres.Add(x => x.CustomerName.Like("P"));
            q.Orders.Add(x => x.CustomerName.Desc());
            q.Orders.Add(x => x.CustomerTypeId.Desc());
            q.Orders.Add(x => x.CustomerId.Desc());
            //q.Orders.Add("CustomerId".TAsc());
            q.Orders.Add(x => x.CustomerId.Asc());
            q.ReturnMatchedCount = true;
             
        }

        [TestMethod]
        public void DbTypeTest()
        {
            Type t = null;
            OracleDbType dbtype = OracleDbType.Blob;
            StringBuilder sb = new StringBuilder();

            t = typeof(Int16);
            dbtype = Oracle.OracleSqlProvider.GetOracleDbType(t);
            sb.AppendFormat("{{ typeof({0}), OracleDbType.{1} }}, \r\n", t, dbtype);

            t = typeof(Int32);
            dbtype = Oracle.OracleSqlProvider.GetOracleDbType(t);
            sb.AppendFormat("{{ typeof({0}), OracleDbType.{1} }}, \r\n", t, dbtype);

            t = typeof(Int64);
            dbtype = Oracle.OracleSqlProvider.GetOracleDbType(t);
            sb.AppendFormat("{{ typeof({0}), OracleDbType.{1} }}, \r\n", t, dbtype);

            t = typeof(DateTime);
            dbtype = Oracle.OracleSqlProvider.GetOracleDbType(t);
            sb.AppendFormat("{{ typeof({0}), OracleDbType.{1} }}, \r\n", t, dbtype); 

            t = typeof(float);
            dbtype = Oracle.OracleSqlProvider.GetOracleDbType(t);
            sb.AppendFormat("{{ typeof({0}), OracleDbType.{1} }}, \r\n", t, dbtype);

            t = typeof(double);
            dbtype = Oracle.OracleSqlProvider.GetOracleDbType(t);
            sb.AppendFormat("{{ typeof({0}), OracleDbType.{1} }}, \r\n", t, dbtype);

            t = typeof(string);
            dbtype = Oracle.OracleSqlProvider.GetOracleDbType(t);
            sb.AppendFormat("{{ typeof({0}), OracleDbType.{1} }}, \r\n", t, dbtype);

            t = typeof(bool);
            dbtype = Oracle.OracleSqlProvider.GetOracleDbType(t);
            sb.AppendFormat("{{ typeof({0}), OracleDbType.{1} }}, \r\n", t, dbtype);

            t = typeof(byte[]);
            dbtype = Oracle.OracleSqlProvider.GetOracleDbType(t);
            sb.AppendFormat("{{ typeof({0}), OracleDbType.{1} }}, \r\n", t, dbtype);

            t = typeof(decimal);
            dbtype = Oracle.OracleSqlProvider.GetOracleDbType(t);
            sb.AppendFormat("{{ typeof({0}), OracleDbType.{1} }}, \r\n", t, dbtype);

            string s = sb.ToString();
        }
    }
}
